package com.danco.sn.entities;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.danco.sn.apientities.ICommunity;
import com.danco.sn.apientities.INews;
import com.danco.sn.apientities.IUser;

@Entity
@Table(name = "user")
public class User implements IUser {
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id_user")
	private Integer idUser;

	@Column(name = "login_user")
	private String login;

	@Column(name = "password_user")
	private String password;

	@Column(name = "first_name")
	private String firstName;

	@Column(name = "last_name")
	private String lastName;

	@Column(name = "number_user")
	private String phoneNumber;

	@Column(name = "sex")
	private String sex;

	@Column(name = "city")
	private String homeCity;

	@Column(name = "birthday")
	@Temporal(value = TemporalType.DATE)
	private Date birthday;
	
	@ManyToMany(mappedBy="members",targetEntity = Community.class, fetch = FetchType.LAZY)
	private List<ICommunity> communityList;
	
	@OneToMany(cascade={CascadeType.ALL},targetEntity = NewsUser.class, fetch=FetchType.LAZY)
	@JoinTable(name="news_user",joinColumns={@JoinColumn(name="id_user")}, 
            inverseJoinColumns={@JoinColumn(name="id_news")})
	private List<INews> listNews;
	

	public List<INews> getListNews() {
		return listNews;
	}

	public void setListNews(List<INews> listNews) {
		this.listNews = listNews;
	}
	
	public List<ICommunity> getCommunityList() {
		return communityList;
	}

	public void setCommunityList(List<ICommunity> communityList) {
		this.communityList = communityList;
	}

	public Integer getIdUser() {
		return idUser;
	}

	public void setIdUser(Integer idUser) {
		this.idUser = idUser;
	}

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public String getHomeCity() {
		return homeCity;
	}

	public void setHomeCity(String homeCity) {
		this.homeCity = homeCity;
	}

	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

}
